﻿function menu(nav){	
	$('li:has(> ul)',nav).addClass('parent');
	$('li:has(> ul) > a',nav).addClass('hasSubnav');
	$("li.parent",nav).hover(function(){
		$(this).addClass('on'); $('> a', this).addClass('hover'); 
		$(this).children("ul").show();
	}, function(){
		$(this).removeClass('on'); $('> a', this).removeClass('hover'); 
		$(this).children("ul").hide();
	});
}
function menuPro(nav){	
	$('li:has(> .levelChild)',nav).addClass('parent');
	$('li:has(> .levelChild) > a',nav).addClass('hasSubnav');
	$("li.parent",nav).hover(function(){
		$(this).addClass('on'); $('> a', this).addClass('hover'); 
	}, function(){
		$(this).removeClass('on'); $('> a', this).removeClass('hover'); 
	});
}
/**
 * @method 选项卡
 * Description
 * e.g tab(".nav",".content","on","mouseover");
 * @nav string 选项卡切换按钮外层的css表达式
 * @nav string 选项卡切换内容外层的css表达式
 * @nav string 当前选项的class名称
 */
function tab(nav,content,on,type)
{
	$(nav).children().bind(type,(function(){
		var $tab=$(this);
		var tab_index=$tab.prevAll().length;
		var $content = $(content).children();
		$(nav).children().removeClass(on);
		$(nav).children().removeClass("next");
		$tab.addClass(on);
		$tab.next().addClass("next");
		$content.hide();
		$content.eq(tab_index).show();
		//$content.eq(tab_index).fadeIn();
	}));
}
function switchIndex(nav,content,on,index){
		var $tab=$(nav).children().eq(index);
		var $content = $(content).children();
		$(nav).children().removeClass(on);
		$tab.addClass(on);
		$content.hide();
		$content.eq(index).show();
		$('html,body').animate({
			scrollTop:1450
		},1500);
}/**
 * @method accordion
 * Description
 * e.g accordion(".nav",".content","on","mouseover");
 * @nav string 选项卡切换按钮外层的css表达式
 * @nav string 选项卡切换内容外层的css表达式
 * @nav string 当前选项的class名称
 */
function accordion(nav,content,on,type){
	$(nav).bind(type, function(){
		var $cur = $(this);	
		$(nav).removeClass(on);
		$(content).hide();
		$cur.addClass(on);
		$cur.next(content).fadeIn();
	})
}

/*页面行为绑定*/
$(function(){
	//menu(".nav");
	//tab(".tabnav",".tabcontent","on","mouseover");
	//accordion(".nav",".content","on","mouseover");
	try{
		$(".hotProducts .inner ").jCarouselLite({	
			btnPrev: ".hotProducts .previous",
			btnNext: ".hotProducts .next",
			visible: 3,
			scroll: 1	
		});	
		$(".hotProducts .previous").hover(function(){$(this).addClass("on");}, function(){$(this).removeClass("on");});
		$(".hotProducts .next").hover(function(){$(this).addClass("on");}, function(){$(this).removeClass("on");});
	}catch(ex){}
	tab(".featuredProducts .featuredProductsN ul",".featuredProducts .featuredProductsC","on","mouseover");
	tab(".describe .sTitle ul",".describe .sContent","on","mouseover");
})

function changeStyle(obj){cName = obj.className; if(cName=="box")  obj.className="on"; else obj.className="box";}

